#include<bits/stdc++.h>
using namespace std;
int d[100005],v[100005],a[100005],p[100005],f1[100005];
vector<int> f2[100005];
int t1[100005],t2[100005];
int need[100005];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;cin>>T;
    while(T--){
        memset(f1,0,sizeof(f1));
        for(int i=1;i<=1e5;i++) f2[i].clear();
        int n,m,L,V,ans1=0,ans2=0;cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++) cin>>d[i]>>v[i]>>a[i];
        for(int i=1;i<=m;i++) cin>>p[i];
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(d[i]<=p[j]){
                    if(sqrt(v[i]*v[i]+2*a[i]*(p[j]-d[i]))>V){
                        f1[i]=1;
                        f2[j].push_back(i);
                    }
                }
            }
        }
        for(int i=1;i<=n;i++){
            ans1+=f1[i];
        }
        memset(need,0,sizeof(need));
        for(int i=1;i<m;i++){
            for(int j=i+1;j<=m;j++){
                memset(t1,0,sizeof(t1));
                memset(t2,0,sizeof(t2));
                for(int k=0;k<f2[i].size();k++){
                    t1[f2[i][k]]=1;
                }
                for(int k=0;k<f2[j].size();k++){
                    t2[f2[j][k]]=1;
                }
                int fl1=1,fl2=1;
                for(int k=1;k<=n;k++){
                    if(t1[k]>t2[k]) fl1=0;
                    if(t1[k]<t2[k]) fl2=0;
                }
                if(fl1&&fl2) fl1=0;
                if(fl1) need[i]=1;
                if(fl2) need[j]=1;
            }
        }
        for(int i=1;i<=m;i++){
            ans2+=need[i];
        }
        cout<<ans1<<' '<<ans2<<endl;
    }
    return 0;
}
